<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title></title>
</head>
<body>
	<div id="app">
		<cpn ref='bbb'></cpn>
		<cpn ref='aaa'></cpn>
		<cpn></cpn>
		<button @click="btnclick">按钮</button>
	</div>
	<template id="cpn">
		<div>
			我是子组件
		</div>
	</template>
	<script src="../js/vue.js"></script>
	<script>
		const app = new Vue({
			el: '#app',
			data: {
				message: '你好啊'
			},
			methods: {
				btnclick(){
					// 用的比较少依  赖于下标 $children (数组类型)
					// console.log(this.$children);
					// this.$children[0].showMessage()
					// console.log(this.$children[0].name)
					
					// 用的多 $refs  (对象类型)
					console.log(this.$refs.aaa.name);
				}
			},
			components: {
				cpn: {
					template: '#cpn',
					data(){
						return {
							name: '我是子组件的name'
						}
					},
					methods: {
						showMessage(){
							console.log('showMessage')
						}
					}
				}
			}
		})
	</script>
</body>
</html>